package com.xl.flinkdemo.source;

import com.xl.flinkdemo.beans.MySensor;
import com.xl.flinkdemo.beans.SensorReding;
import org.apache.flink.api.common.serialization.SimpleStringSchema;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer011;

import java.util.Properties;

/**
 * @ClassName SourceTest_Collecttion_zidingyi
 * @Description 自定义source,实现SourceFunction接口
 * @Author hxl
 * @Date 2021/4/14 15:08
 * Version 1.0
 **/
public class SourceTest_Collecttion_zidingyi {

  public static void main(String[] args) throws Exception {
    //创建执行环境
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

    //按顺序输出
    env.setParallelism(1);

    //自定义数据源
    DataStream<SensorReding> dataStream = env.addSource(new MySensor());

    //打印输出
    dataStream.print();

    //执行
    env.execute("jobName_TestSourceJob");
  }

}
